# -*- coding: utf-8 -*- 
import settings
import wx, wx.lib.pubsub as pubsub

class Calculator:
    def __init__(self, dots):
        self.dots = dots
        self.result = []
        self.title = 'Result:'
        
    #these two methods needed to be inherted    
    def prepare_raw_data(self):pass
    def prepare_title(self, t):pass
    
    def get_ready(self):
        self.prepare_raw_data()
        self.prepare_title()
        if len(self.result) == 0: return
        
        r = self.result[0]
        for i in self.result[1:]:
            row = []
            for j in i:
                if settings.unit == 'cm':
                    j =  int(j/settings.scale * settings.accuracy + 0.5) /settings.accuracy
                row.append( str(j) )
            r.append(row)    
        self.result = r
        
        pubsub.Publisher().sendMessage("CALCULATOR GETS READY", 'calculator got the results')
        